package com.ihr360.job.core.step.tasklet;


import com.ihr360.job.core.entity.StepContribution;
import com.ihr360.job.core.repeat.RepeatStatus;
import com.ihr360.job.core.scope.context.ChunkContext;

/**
 * Strategy for processing in a step.
 *
 * @author Dave Syer
 *
 */
public interface Tasklet {

    /**
     * Given the current context in the form of a step contribution, do whatever
     * is necessary to process this unit inside a transaction. Implementations
     * return {@link RepeatStatus#FINISHED} if finished. If not they return
     * {@link RepeatStatus#CONTINUABLE}. On failure throws an exception.
     *
     * @param contribution mutable state to be passed back to update the current
     * step execution
     * @param chunkContext attributes shared between invocations but not between
     * restarts
     * @return an {@link RepeatStatus} indicating whether processing is
     * continuable.
     */
    RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception;

}